package pojo;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

// 简单的用注解 复杂的用xml
public interface UserDao {

    @Insert("insert into user values(#{id}, #{name})")
    void addUser(User u);

    // 基础参数最好用@Param声明
    @Delete("delete from user where id = #{id}")
    void delectUser(@Param("id") int id);

    // xml配置
    List<User> queryUsers();

    @Select("select * from user where id = #{id}")
    User queryUserById(@Param("id") int id);

    @Update("update user set name = #{name} where id = #{id}")
    void update(User u);

    User queryOneUserWithResultMap(int id);

    @Select("select * from user limit #{num}, #{page}")
    List<User> queryUserLimit(@Param("num")int num, @Param("page")int page);


    List<User> queryUserIf(Map map);

    // 动态sql
    List<User> queryUserIn(List<Integer> list);

}
